<body class="inside-header inside-aside is-dialog">
<div id="main" role="main">
    <div class="tab-content tab-addtabs">
        <div id="content">
            <div class="row">
                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                    <section class="content-header hide">
                        <h1>
                            控制台 <small>Control panel</small>
                        </h1>
                    </section>
                    <div class="content">
                        <style>
                            .panel-fieldlist .fieldlist dd ins {
                                width: 20%;
                            }

                            .panel-fieldlist .fieldlist dd input, .panel-fieldlist .fieldlist dd select {
                                width: 100%;
                            }

                            .list-group-item {
                                display: flex;
                                align-items: center;
                                justify-content: space-between;
                            }

                            .groups {
                                display: flex;
                                align-items: center;
                            }

                            .title {
                                font-weight: bold;
                                font-size: 16px;
                            }

                            .list-group .list-group-item .label {
                                padding: 5px 10px;
                            }

                            .table-goods > thead > tr > th, .table-goods > tbody > tr > th, .table-goods > thead > tr > td, .table-goods > tbody > tr > td {
                                vertical-align: middle;
                            }

                            .order-status {
                                display: flex;
                                justify-content: space-between;
                                align-items: center;
                            }

                            .print-flex {
                                display: flex;
                                justify-content: space-between;
                                align-items: center;
                            }

                            @media print {
                                .electronics, .btn-print-page, .memo-operate {
                                    display: none;
                                }
                            }
                        </style>
                        <div id="app">
                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    订单信息
                                    <a href="javascript:;" onclick="window.print();"
                                       class="btn btn-info btn-xs pull-right btn-print-page">
                                        <i class="fa fa-print"></i>
                                        打印
                                    </a>
                                </div>
                                <div class="panel-body">
                                    <div class="row">
                                        <div class="col-xs-6">
                                            <ul class="list-group">
                                                <button class="btn-refresh hidden"></button>
                                                <input type="hidden" id="order_id" value="{$row.id}">
                                                <input type="hidden" id="now-status" value="{$row.status}">
                                                <input type="hidden" id="amount" value="{$row.total_fee}">
                                                <input type="hidden" id="shippingfee" value="{$row.pay_price}">
                                                <li class="list-group-item">唯一订单号：{$row.unique_order_no}</li>
                                                <li class="list-group-item">订单号：{$row.order_no}</li>
                                                <!--@formatter:off-->
                                                <li class="list-group-item order-status">
                                                    <div>
                                                        订单状态：
                                                        <span class="label label-danger">{$row.status_text}</span>
                                                    </div>
                                                    <div>
                                                        {if $row.status == 0}
                                                        <button type="button" class="btn btn-success btn-status-click" data-order='{"orderstate":5}'>取消</button>
                                                        <button type="button" class="btn btn-success btn-status-click" data-order='{"paystate":1}'>设为已支付</button>
                                                        {/if}
                                                        {if $row.status == 1}
                                                            <button type="button" class="btn btn-success btn-deliver" data-expressname="" data-expressno="" data-type="0">发货</button>
                                                        {/if}
                                                        {if $row.status == 2}
                                                        <!--<button type="button" class="btn btn-success btn-deliver" data-expressname="EMS" data-expressno="123123" data-type="1">修改快递</button>-->
                                                        {/if}

                                                        {if in_array($row.status,[2])}
                                                        <button type="button" class="btn btn-success btn-status-click" data-order='{"orderstate":3}'>设为已完成</button>
                                                        {/if}
                                                    </div>
                                                </li>
                                                <!--@formatter:on-->
                                                <li class="list-group-item">下单用户：{$row.user.nickname}（用户ID：{$row.user_id}）</li>
                                                <li class="list-group-item">商品费用：￥{$row.goods_price}</li>
                                                <li class="list-group-item">快递费用：￥{$row.delivery_price}</li>
                                                <li class="list-group-item">折扣金额：￥{$row.coupon_price}</li>
                                                <li class="list-group-item">订单金额：￥{$row.order_price}</li>
<!--                                                <li class="list-group-item">应付金额：￥{$row.total_fee}</li>-->
                                                <li class="list-group-item">
                                                    <div class="groups">
                                                        <span style="min-width: 75px;">应付金额：</span>
                                                        <div>￥{$row.total_fee}</div>
                                                        <input class="form-control hide" type="number" value="{$row.total_fee}">
                                                    </div>
                                                    {if $row.status == 0}
                                                    <div class="memo-operate">
                                                        <a class="btn btn-success btn-edit" data-status="edit"
                                                           href="javascript:;">改价</a>
                                                        <a class="btn btn-success hide btn-cancel" data-status="cancel"
                                                           href="javascript:;">取消</a>
                                                        <a class="btn btn-success hide btn-save" data-status="save"
                                                           data-field="total_fee" data-id="{$row.id}" href="javascript:;">保存</a>
                                                    </div>
                                                    {/if}
                                                </li>
                                                <li class="list-group-item">实付金额：￥{$row.pay_price}</li>
<!--                                                <li class="list-group-item">-->
<!--                                                    <span style="width: 140px;">退款金额：￥0.00</span>-->
<!--                                                    <span></span>-->
<!--                                                </li>-->
                                                <li class="list-group-item">
                                                    <div>
                                                        发货类型：{$row.dispatch_type_text}
                                                    </div>
                                                    {if $row.dispatch_type == 'ziti'}
                                                    <div>取件码: {$row.claim_code}</div>
                                                    {/if}
                                                </li>
                                            </ul>
                                        </div>
                                        <div class="col-xs-6">
                                            <ul class="list-group">
                                                <li class="list-group-item">下单时间：{$row.createtime|date='Y-m-d H:i:s',###}</li>
                                                <li class="list-group-item">支付类型：{$row.pay_type_text}</li>
                                                <li class="list-group-item">交易流水号：{$row.trade_no}</li>
                                                <li class="list-group-item">支付时间：{$row.pay_time_text}</li>
<!--                                                <li class="list-group-item">退货时间：{$row.pay_time_text}</li>-->
                                                <li class="list-group-item">发货时间：{$row.delivery_time_text}</li>
                                                <li class="list-group-item">收货时间：{$row.received_time_text}</li>
                                                <li class="list-group-item">取消时间：{$row.cancel_time_text}</li>
                                                <li class="list-group-item">关闭时间：{$row.close_time_text}</li>
                                                <li class="list-group-item">下单店铺：{$row.shop.nickname??''}</li>
                                                <li class="list-group-item">取货店铺：{$row.claimshop.nickname??''}</li>
                                                <li class="list-group-item">
                                                    <div class="groups">
                                                        <span style="min-width: 75px;">备注信息：{$row.remark}</span>
                                                        <div></div>
                                                        <input class="form-control hide" type="text" value="">
                                                    </div>
                                                    <div class="memo-operate">
                                                        <a class="btn btn-success btn-edit" data-status="edit"
                                                           href="javascript:;">编辑</a>
                                                        <a class="btn btn-success hide btn-cancel" data-status="cancel"
                                                           href="javascript:;">取消</a>
                                                        <a class="btn btn-success hide btn-save" data-status="save"
                                                           data-field="remark" data-id="{$row.id}" href="javascript:;">保存</a>
                                                    </div>
                                                </li>
                                            </ul>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!-- 收货信息 -->
                            <div class="panel panel-default">
                                <div class="panel-heading print-flex">
                                    <span>收货信息</span>
                                </div>
                                <div class="panel-body">
                                    <div class="row">
                                        <div class="col-xs-6">
                                            <p>收货人的姓名：{$row.contact}</p>
                                            <p>收货人的手机：{$row.mobile}</p>
                                            <p>收货人的地址：{$row.province}{$row.city}{$row.area}{$row.address}</p>
                                        </div>
<!--                                        <div class="col-xs-6">-->
<!--                                            <p>发货快递名称：</p>-->
<!--                                            <p>发货快递单号：</p>-->
<!--                                        </div>-->
                                    </div>
                                </div>
                            </div>
                            <!-- 快递信息 -->
                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    <span>快递信息</span>
                                </div>
                                <div class="panel-body">
                                    <table class="table table-bordered table-goods">
                                        <thead>
                                        <tr>
                                            <th>快递公司</th>
                                            <th>公司编号</th>
                                            <th>快递单号</th>
                                            <th>操作</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        {notempty name="$row.express"}
                                        {foreach $row.express as $express}
                                        <tr>
                                            <td>{$express.express_name}</td>
                                            <td>{$express.express_code}</td>
                                            <td>{$express.express_no}</td>
                                            <td>
                                                {if in_array($row.status,[2,3])}
<!--                                                <button type="button" class="btn btn-success btn-logistics" data-expressno="{$express.express_no}">查询物流</button>-->
                                                <a class="btn btn-success btn-logistics" href="https://www.kuaidi100.com/" target="_blank">查询物流</a>
                                                {/if}
                                            </td>
                                        </tr>
                                        {/foreach}
                                        {/notempty}
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                            <!-- 商品信息 -->
                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    <span>商品信息</span>
                                </div>
                                <div class="panel-body">
                                    <div class="goods">
                                        <table class="table table-bordered table-goods">
                                            <thead>
                                            <tr>
                                                <th class="text-center">商品ID</th>
                                                <th>名称</th>
                                                <th class="text-center">图片</th>
                                                <th class="text-center">规格</th>
<!--                                                <th class="text-center">售价</th>-->
                                                <th class="text-center">售价</th>
                                                <th class="text-center">数量</th>
                                                <th class="text-center">商品总价</th>
                                                <th class="text-center">优惠金额</th>
                                                <th class="text-center">运费</th>
                                                <th class="text-center">总金额</th>
<!--                                                <th class="text-center">售后状态</th>-->
                                            </tr>
                                            </thead>
                                            <tbody>
                                            {notempty name="$row.item"}
                                            {foreach $row.item as $goods}
                                            <tr>
                                                <th class="text-center" scope="row">{$goods.goods_id}</th>
                                                <td>{$goods.goods_name}</td>
                                                <td class="text-center">
                                                    <a href="{$goods.image?:'javascript:'}" target="_blank">
                                                        <img style="cursor: pointer;" data-tips-image src="{$goods.image}" class="img-sm" alt="">
                                                    </a>
                                                </td>
                                                <td class="text-center">{$goods.goods_spec_str}</td>
<!--                                                <td class="text-center">{$goods.spec.spec_price}</td>-->
                                                <td class="text-center">{$goods.price}</td>
                                                <td class="text-center">{$goods.num}</td>
                                                <td class="text-center">{$goods.total_price}</td>
                                                <td class="text-center">{$goods.coupon_price}</td>
                                                <td class="text-center">{$goods.delivery_price}</td>
                                                <td class="text-center">{$goods.total_fee}</td>
<!--                                                <td class="text-center">{$goods.is_sales_text}</td>-->
                                            </tr>
                                            {/foreach}
                                            {/notempty}
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <span>订单操作日志</span>
                            </div>
                            <div class="panel-body">
                                <table class="table table-bordered table-goods">
                                    <thead>
                                    <tr>
                                        <th>ID</th>
                                        <th>操作人</th>
                                        <th>操作记录</th>
                                        <th>操作时间</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    {notempty name="$row.action"}
                                    {foreach $row.action as $key => $action}
                                    <tr>
                                        <th scope="row">{$key + 1}</th>
                                        <td>{$action.oper_type_text}</td>
                                        <td>{$action.remark}</td>
                                        <td>{$action.createtime|date='Y-m-d H:i:s',###}</td>
                                    </tr>
                                    {/foreach}
                                    {/notempty}
                                    </tbody>
                                </table>
                            </div>
                        </div>

                        <script type="text/html" id="expresstpl">
                            <div style="padding:15px 15px 0 15px;">
                                <ul class="list-group">
                                    <p style="color: darkred;">注: 多个包裹请敲回车键键入单号</p>
                                    <li class="list-group-item shipper">
                                        <label class="control-label" style="width:73px;">快递名称：</label>
                                        <input class="form-control selectpage" data-primary-key="name" data-order-by="id" data-source="kuaidi/selectpage" style="flex:1;" id="express_name" value="<%=express_name%>"/>
                                    </li>
                                    <li class="list-group-item">
                                        <label class="control-label" style="width:73px;">快递单号：</label>
                                        <input class="form-control" style="flex:1;" id="express_no" name="express_no" value="<%=express_no%>"/>
<!--                                        <textarea class="form-control" style="flex:1;" name="express_no" id="express_no" cols="30" rows="5"><%=express_no%></textarea>-->

                                    </li>
                                </ul>
                            </div>
                        </script>

                        <script type="text/html" id="invoicetpl">
                            <%for(var i=0;i < orderList.length;i++){%>
                            <%var order=orderList[i];%>
                            <div style="padding:0px;page-break-after: always;">
                                <h3 style="padding: 8px 5px;">发货单</h3>
                                <table style="width:100%;font-size:14px;" class="baseinfo">
                                    <tr>
                                        <td style="width:50%">
                                            <div>订单号：<%=order.order_sn%></div>
                                        </td>
                                        <td>
                                            <div>用户：<%=order.user && order.user.nickname%></div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="width:50%">地址：<%=order.address%></td>
                                        <td>总件数：<%=order.nums%></td>
                                    </tr>
                                </table>
                                <table style="width:100%;font-size:14px;" class="deliverytable">
                                    <thead>
                                    <tr>
                                        <th>商品ID</th>
                                        <th>
                                            <div style="width:50px;">货号</div>
                                        </th>
                                        <th style="text-align: left;">
                                            <div style="width:220px;">名称</div>
                                        </th>
                                        <th>
                                            <div style="width:100px;">属性</div>
                                        </th>
                                        <th>市场价</th>
                                        <th>商城价</th>
                                        <th>数量</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <%for(var j=0;j< order.order_goods.length;j++){%>
                                    <%var goods=order.order_goods[j];%>
                                    <tr>
                                        <td><%=goods.goods_id%></td>
                                        <td>
                                            <div style="width:50px;"><%=goods.goods_sn || '无'%></div>
                                        </td>
                                        <td style="text-align: left;">
                                            <div style="width:220px;"><%=goods.title%></div>
                                        </td>
                                        <td>
                                            <div style="width:100px;"><%=goods.attrdata || '无'%></div>
                                        </td>
                                        <td><%=goods.price%></td>
                                        <td><%=goods.marketprice%></td>
                                        <td><%=goods.nums%></td>
                                    </tr>
                                    <%}%>
                                    </tbody>
                                </table>
                            </div>
                            <style>
                                .baseinfo tr td {
                                    padding: 6px;
                                }

                                .baseinfo {
                                    margin-bottom: 15px;
                                }

                                .deliverytable tr th {
                                    background: #f7f7f7;
                                }

                                .deliverytable tr td {
                                    border-bottom: 1px solid #eee;
                                }

                                .deliverytable tr td, .deliverytable tr th {
                                    padding: 8px 5px;
                                    text-align: center;
                                }
                            </style>
                            <%}%>
                        </script>


                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>

<script>
    $('body').on('click', '[data-tips-image]', function () {
        var img = new Image();
        var imgWidth = this.getAttribute('data-width') || '480px';
        img.onload = function () {
            var $content = $(img).appendTo('body').css({background: '#fff', width: imgWidth, height: 'auto'});
            Layer.open({
                type: 1, area: imgWidth, title: false, closeBtn: 1,
                skin: 'layui-layer-nobg', shadeClose: true, content: $content,
                end: function () {
                    $(img).remove();
                },
                success: function () {

                }
            });
        };
        img.onerror = function (e) {

        };
        img.src = this.getAttribute('data-tips-image') || this.src;
    });
</script>